<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * Smarty {dish_search_menus} function plugin
 * @param array|null $params
 * @param Smarty $smarty
 */
function smarty_function_dish_search_menus($params, $smarty) {
    
    $smarty->CI->load->model('restaurant/menus_model');
    $data = $smarty->CI->menus_model->get_menus_withtotal();
    if (!$data) {
        return '';
    }

    $ci =& get_instance();
    $ci->load->helper('text');
    $html = '';

    foreach ($data as $item) {
        $alias = create_url('loai-mon/'.$item['alias'], array('rewrite'=>true));
        $html .= "<div class=\"list-filters-item\">
                  <input type=\"checkbox\" value=\"{$item['menu_id']}\" name=\"filter_menu[]\" id=\"filter_menu[]\"/>
                        <span data-bind=\"text: {$item['name']}\">
                        <a href=\"{$alias}\" title=\"{$item['name']}\">{$item['name']}</a>
                        </span>
                        <div class=\"right_c\">{$item['total']}</div>
                    </div>";
    }
    return $html . "<br/>";
}
